<?php
/**
 * wrapper class for userrole table
 * @package naanal
 */
class ClsWRolepermission extends ClsWrapper
{
	/**
         * id
         * @package naanal
         * @var integer 
         */
        protected $id=null;
        /**
         * role_id
         * @package naanal
         * @var integer 
         */
  	protected $role_id=null;
        /**
         * permission_id
         * @package naanal
         * @var integer 
         */
  	protected $permission_id=null;
        /**
         * pdo
         * @package naanal
         * @var string 
         */
  	private $pdo=null;
	  
  public $tableName=null;
  /**
   * construct
   * @package naanal
   */
	function __construct($module=false)
	{
            parent::__construct($module);
	}
	/**
         * get_id
         * @package naanal
         * @return integer
         */
	function get_id()
	{
		return $this->id;
	}
        /**
         * set_id
         * @package naanal
         * @param integer $id
         */
	function set_id($id)
	{
		$this->id=$id;
	}
	/**
         * get_role_id
         * @package naanal
         * @return integer
         */
  	public function get_role_id()
  	{
  		return $this->role_id;
  	}
  	/**
         * role_id
         * @package naanal
         * @param integer $role_id
         */
  	public function set_role_id($role_id)
  	{
  		$this->role_id=$role_id;
  	}
  	/**
         * get_permission_id
         * @package naanal
         * @return integer
         */
	public function get_permission_id()
  	{
  		return $this->permission_id;
  	}
  	/**
         * set_permission_id
         * @package naanal
         * @param integer $permission_id
         */
  	public function set_permission_id($permission_id)
  	{
  		$this->permission_id=$permission_id;
  	}
  	/**
         * get_role_lookup
         * @package naanal
         * @return string
         */
  	public function get_role_lookup()
  	{
		$this->pdo->setQuery("select * from role");
  		$arrObj=$this->pdo->getAllObject("ClsWRole");
  		$select='<select name="role_id">
		<option value="">- Select -</option>';
		if($arrObj)
		foreach($arrObj as $ind=>$obj)
		{
			$selected="";
			if($obj->get_id()==$this->get_role_id()) $selected=" selected";
			$select=$select.'<option value="'.$obj->get_id().'"'.$selected.'>'.$obj->get_name().'</option>';	
		}  		
		$select=$select.'</select>';
		return $select;
	}
	 /**
          * get_role
          * @package naanal
          * @return string
          */
	public function get_role()
  	{
  		$this->pdo->setQuery("select * from role where id=".$this->role_id);
  		$obj = $this->pdo->getObject("ClsWRole");
  		return $obj;
	}
	/**
         * get_permission_lookup
         * @package naanal
         * @return string
         */
	public function get_permission_lookup()
  	{
		$this->pdo->setQuery("select * from permission");
  		$arrObj=$this->pdo->getAllObject("ClsWPermission");
  		$select='<select name="user_id">
		<option value="">- Select -</option>';
		foreach($arrObj as $ind=>$obj)
		{
			$selected="";
			if($obj->get_id()==$this->get_user_id()) $selected=" selected";
			$select=$select.'<option value="'.$obj->get_id().'"'.$selected.'>'.$obj->get_name().'</option>';	
		}  		
		$select=$select.'</select>';
		return $select;
	}   
  	/**
         * get_permission
         * @package naanal
         * @return string
         */
  	public function get_permission()
  	{
  		$this->pdo->setQuery("select * from permission where id=".$this->permission_id);
  		$obj = $this->pdo->getObject("ClsWPermission");
  		return $obj;
	}
  	/**
         * getArray
         * @package naanal
         * @return array
         */
	function getArray()
	{
		$arr=null;
		$arr["id"]=$this->get_id();
  		$arr["role_id"]=$this->get_role_id();
  		$arr["permission_id"]=$this->get_permission_id();
		return $arr;
	}
        /**
         * setArray
         * @package naanal
         * @param array $arr
         * @return array
         */
	function setArray($arr)
	{
		if(isset($arr["id"])) $this->set_id($arr["id"]);
  		if(isset($arr["role_id"])) $this->set_role_id($arr["role_id"]);
  		if(isset($arr["permission_id"])) $this->set_permission_id($arr["permission_id"]);
		return $arr;		
	}	  
}	
?>